/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Room;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author mishra
 */
public class RoomNumber extends HttpServlet {

   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            int no=Integer.parseInt(request.getParameter("no"));
            int hid=Integer.parseInt(request.getParameter("hid"));
            int rno=Integer.parseInt(request.getParameter("rno"));
            out.println("<center style='float:left;margin-left:175px;'><table align='center'><tr><thead style='color: white; background-color: #cc6600;' class='table table-striped dataTable-noheader dataTable-nofooter table-bordered'>");
            out.println("<th>Room Number</th>");
            out.println("<th>Number of Beds</th>");
            out.println("<th>Additional Room Rent</th>");
            out.println("</thead></tr><tbody>");
            for(int i=rno;i<=(no+rno)-1;i++)
            {
            out.println("<tr><td>");
            out.println("<input type='text' name='"+i+"-"+hid+"' style='color: black' value='R-"+i+"-"+hid+"' readOnly>");
            out.println("</td><td>");
            out.println("<input type='text' name='room-"+i+"' class='required'>");
            out.println("</td><td>");
            out.println("<input type='text' name='fees-"+i+"' value='0' class='required'>");
            out.println("</td></tr>");
            }
            out.println("</tbody></table></center>");
            
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
